import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/pages/clubs/player_info/player_info_controller.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:get/get.dart';

class ManageDialog {

  static void show(
    BuildContext mContext, {
      Function? confirmTap,
      Function? cancelTap,
    }
  ) {
    showDialog(
      // barrierDismissible: false,
      context: mContext,
      builder: (BuildContext context) {
        return ShowDialogPage(
          confirmTap: confirmTap,
          cancelTap: cancelTap,
        );
      }
    );
  }

}




class ShowDialogPage extends Dialog {
  ShowDialogPage({
    this.confirmTap,
    this.cancelTap,
  });

  // 确认
  final Function? confirmTap;
  final Function? cancelTap;

  @override
  Widget build(BuildContext dContext) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      //自定义dialog布局
      child: GetBuilder<PlayerInfoController>(
        builder: (playerInfoController) {
          return Center(
            child: RichText(
              text: TextSpan(
                children: [
                  WidgetSpan(
                    child: Container(
                      margin: EdgeInsets.symmetric(horizontal: 40.w),
                      width: double.infinity,
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(12.r)
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Container(
                            alignment: Alignment.center,
                            height: 48.w,
                            decoration: BoxDecoration(
                              gradient: const LinearGradient(
                                begin: Alignment.topCenter,
                                end: Alignment.bottomCenter,
                                colors: [
                                  Color(0xFFEAF9EF),
                                  Color(0x00EAF9EF),
                                ],
                                stops: [0.0, 1.0],
                              ),
                              borderRadius: BorderRadius.circular(12.r)
                            ),
                            child: Text("球员管理", style: TextStyle(fontSize: 17.sp, fontWeight: FontWeight.w500, color: const Color(0xff499265), ), textAlign: TextAlign.center,),
                          ),

                          SizedBox(height: 12.w,),

                          Container(
                            margin: EdgeInsets.symmetric(horizontal: 26.w),
                            child: GestureDetector(
                              behavior: HitTestBehavior.translucent,
                              onTap: () {
                                playerInfoController.changeSelectRlType(0);
                              },
                              child: Container(
                                decoration: BoxDecoration(
                                  color: playerInfoController.selectRlTypeIndex == 0 ? const Color(0xff499360).withOpacity(0.10) : Colors.transparent,
                                  borderRadius: BorderRadius.circular(8.r)
                                ),
                                padding: EdgeInsets.symmetric(vertical: 10.w),
                                alignment: Alignment.center,
                                child: Text('任命为管理员', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: playerInfoController.selectRlTypeIndex == 0 ? const Color(0xff499360) : const Color(0xff333333), ), textAlign: TextAlign.center,),
                              ),
                            ),
                          ),

                          SizedBox(height: 12.w,),

                          Container(
                            margin: EdgeInsets.symmetric(horizontal: 26.w),
                            child: GestureDetector(
                              behavior: HitTestBehavior.translucent,
                              onTap: () {
                                playerInfoController.changeSelectRlType(1);
                              },
                              child: Container(
                                padding: EdgeInsets.symmetric(vertical: 10.w),
                                alignment: Alignment.center,
                                decoration: BoxDecoration(
                                    color: playerInfoController.selectRlTypeIndex == 1 ? const Color(0xff499360).withOpacity(0.10) : Colors.transparent,
                                    borderRadius: BorderRadius.circular(8.r)
                                  ),
                                child: Text('任命为财务', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: playerInfoController.selectRlTypeIndex == 1 ? const Color(0xff499360) : const Color(0xff333333), ), textAlign: TextAlign.center,),
                              ),
                            ),
                          ),

                          SizedBox(height: 12.w,),

                          Container(
                            margin: EdgeInsets.symmetric(horizontal: 26.w),
                            child: GestureDetector(
                              behavior: HitTestBehavior.translucent,
                              onTap: () {
                                playerInfoController.changeSelectRlType(2);
                              },
                              child: Container(
                                padding: EdgeInsets.symmetric(vertical: 10.w),
                                alignment: Alignment.center,
                                decoration: BoxDecoration(
                                    color: playerInfoController.selectRlTypeIndex == 2 ? const Color(0xff499360).withOpacity(0.10) : Colors.transparent,
                                    borderRadius: BorderRadius.circular(8.r)
                                  ),
                                child: Text('解除当前职务', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: playerInfoController.selectRlTypeIndex == 2 ? const Color(0xff499360) : const Color(0xff333333), ), textAlign: TextAlign.center,),
                              ),
                            ),
                          ),

                          SizedBox(height: 12.w,),

                          Container(
                            margin: EdgeInsets.symmetric(horizontal: 26.w),
                            child: GestureDetector(
                              behavior: HitTestBehavior.translucent,
                              onTap: () {
                                playerInfoController.changeSelectRlType(3);
                              },
                              child: Container(
                                padding: EdgeInsets.symmetric(vertical: 10.w),
                                alignment: Alignment.center,
                                decoration: BoxDecoration(
                                    color: playerInfoController.selectRlTypeIndex == 3 ? const Color(0xff499360).withOpacity(0.10) : Colors.transparent,
                                    borderRadius: BorderRadius.circular(8.r)
                                  ),
                                child: Text('踢出俱乐部', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: playerInfoController.selectRlTypeIndex == 3 ? const Color(0xff499360) : const Color(0xff333333), ), textAlign: TextAlign.center,),
                              ),
                            ),
                          ),

                          SizedBox(height: 12.w,),

                          Container(
                            margin: EdgeInsets.symmetric(horizontal: 26.w),
                            child: GestureDetector(
                              behavior: HitTestBehavior.translucent,
                              onTap: () {
                                playerInfoController.changeSelectRlType(4);
                              },
                              child: Container(
                                padding: EdgeInsets.symmetric(vertical: 10.w),
                                alignment: Alignment.center,
                                decoration: BoxDecoration(
                                    color: playerInfoController.selectRlTypeIndex == 4 ? const Color(0xff499360).withOpacity(0.10) : Colors.transparent,
                                    borderRadius: BorderRadius.circular(8.r)
                                  ),
                                child: Text('移交主席位置', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: playerInfoController.selectRlTypeIndex == 4 ? const Color(0xff499360) : const Color(0xff333333), ), textAlign: TextAlign.center,),
                              ),
                            ),
                          ),


                          SizedBox(height: 16.w,),


                          Container(
                            padding: EdgeInsets.symmetric(horizontal: 20.w),
                            child: Row(
                              children: [
                                Expanded(
                                  child: GestureDetector(
                                    behavior: HitTestBehavior.translucent,
                                    onTap: () {
                                      cancelTap?.call();
                                    },
                                    child: Container(
                                      padding: EdgeInsets.symmetric(vertical: 12.w),
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.circular(8.r),
                                        border: Border.all(
                                          width: 1.w,
                                          color: const Color(0xff999999)
                                        )
                                      ),
                                      alignment: Alignment.center,
                                      child: Text('取消', style: TextStyle(fontSize: 14.sp, color: const Color(0xff999999), fontWeight: FontWeight.w500),),
                                    ),
                                  ),
                                ),
                                SizedBox(width: 18.w,),
                                Expanded(
                                  child: GestureDetector(
                                    behavior: HitTestBehavior.translucent,
                                    onTap: () {
                                      confirmTap?.call();
                                    },
                                    child: Container(
                                      padding: EdgeInsets.symmetric(vertical: 12.w),
                                      decoration: BoxDecoration(
                                        color: const Color(0xff499360),
                                        borderRadius: BorderRadius.circular(8.r),
                                        border: Border.all(
                                          width: 1.w,
                                          color: const Color(0xff499360)
                                        )
                                      ),
                                      alignment: Alignment.center,
                                      child: Text('确认', style: TextStyle(fontSize: 14.sp, color: Colors.white, fontWeight: FontWeight.w500),),
                                    ),
                                  ),
                                )
                              ],
                            ),
                          ),

                          SizedBox(height: 20.w,)
                        ],
                      ),
                    )
                  ),
                ]
              ),
            ),
          );
        }
      )
    );
  }
}



